package com.hsmw.api.service;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hsmw.api.mapper.HsmwItemMapper;
import com.hsmw.api.mapper.HsmwPushInfoMapper;
import com.hsmw.api.mapper.HsmwRechargeRecordMapper;
import com.hsmw.common.base.BaseService;
import com.hsmw.domain.HsmwOrder;
import com.hsmw.domain.HsmwPushInfo;
import com.hsmw.domain.HsmwRechargeRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class HsmwRechargeRecordService extends BaseService<HsmwRechargeRecordMapper, HsmwRechargeRecord> {

    @Autowired
    private HsmwRechargeRecordMapper hsmwRechargeRecordMapper;

    public IPage<HsmwRechargeRecord> selectpageList(IPage page, HsmwRechargeRecord hsmwRechargeRecord) {
        LambdaQueryWrapper<HsmwRechargeRecord> lambdaQuery = Wrappers.lambdaQuery(HsmwRechargeRecord.class);
        if (StrUtil.isNotBlank(hsmwRechargeRecord.getRechargeType())) {
            lambdaQuery.eq(HsmwRechargeRecord::getRechargeType, hsmwRechargeRecord.getRechargeType());
        }
        if (StrUtil.isNotBlank(hsmwRechargeRecord.getRechargeStatus())) {
            lambdaQuery.eq(HsmwRechargeRecord::getRechargeStatus, hsmwRechargeRecord.getRechargeStatus());
        }
        if (StrUtil.isNotBlank(hsmwRechargeRecord.getCompanyId())) {
            lambdaQuery.eq(HsmwRechargeRecord::getCompanyId, hsmwRechargeRecord.getCompanyId());
        }
        lambdaQuery.orderByDesc(HsmwRechargeRecord::getCreateTime);
        IPage<HsmwRechargeRecord> orderIPage = hsmwRechargeRecordMapper.selectPage(page, lambdaQuery);
        return orderIPage;
    }
}
